// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  let {openid,updateData}=event
  let db=cloud.database()
  let res=await db.collection('user').where({openid:openid}).update({
    data:{
      avatar: updateData.avatar,
      username: updateData.username,
      gender: updateData.gender,
      birthday: updateData.birthday,
      email: updateData.email,
      updated_at: db.serverDate() // 添加更新时间
    }
  })
  return {
    success:true,
    data:res
  }
}